package com.slz3.business.module.apiAliyun.aliyunOSS;

import com.slz3.business.frame.route.Pattern;
import org.springframework.http.MediaType;
import org.springframework.web.reactive.function.server.RequestPredicate;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.ServerResponse;

import static org.springframework.web.reactive.function.server.RequestPredicates.POST;
import static org.springframework.web.reactive.function.server.RequestPredicates.accept;
import static org.springframework.web.reactive.function.server.RouterFunctions.route;

public class AliyunOSSRouter {

    private static RequestPredicate MULTIPART = accept(MediaType.MULTIPART_FORM_DATA);

    public static RouterFunction<ServerResponse> funs(AliyunOSSHandler handler) {
        return route(POST(Pattern.UPLOAD_OBJECT).and(MULTIPART), handler::uploadObject);
    }

}
